package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.generator.entity.TeTeacherEntity;
import io.renren.modules.generator.service.TeTeacherService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * ${comments}
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-09-29 08:45:21
 */
@RestController
@RequestMapping("/teteacher")
public class TeTeacherController {
    @Autowired
    private TeTeacherService teTeacherService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:teteacher:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = teTeacherService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{teId}")
    @RequiresPermissions("generator:teteacher:info")
    public R info(@PathVariable("teId") Integer teId){
		TeTeacherEntity teTeacher = teTeacherService.getById(teId);

        return R.ok().put("teTeacher", teTeacher);
    }

    @GetMapping("/getAll")
    public R getAll(){
        List<TeTeacherEntity> all = teTeacherService.getAll();
        return R.ok().put("ip:121;port:8080,res",all);
    }
    @PostMapping("/test")
    public R test(@RequestParam("name") String name){
        //写在url里
        return R.ok().put("res",name);
    }


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:teteacher:save")
    public R save(@RequestBody TeTeacherEntity teTeacher){
		teTeacherService.save(teTeacher);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:teteacher:update")
    public R update(@RequestBody TeTeacherEntity teTeacher){
		teTeacherService.updateById(teTeacher);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:teteacher:delete")
    public R delete(@RequestBody Integer[] teIds){
		teTeacherService.removeByIds(Arrays.asList(teIds));

        return R.ok();
    }

}
